<template>
      <el-table
        key="2"
        ref="table"
        style="width: 100%;margin-top:20px"
        :data="dataList"
        @selection-change="selectChange"
        border
        v-loading="dataListLoading">
                <el-table-column type="selection" width="55" header-align="center" align="center"></el-table-column>
                <el-table-column type="index" width="80" header-align="center" align="center" label="序号"></el-table-column>
                <el-table-column
                    prop="shouyueName"
                    header-align="center"
                    align="center"
                    min-width="120"
                    label="受约人姓名">
                    <template slot-scope="scope">
                      <div v-for="(item,index) in cutout(scope.row.shouyueName).slice(0, 2)">
                        <el-tooltip class="item" :disabled="cutout(scope.row.shouyueName).length<3" effect="dark" :content="scope.row.shouyueName" placement="top-start">
                          <span>{{item}}<span v-if="cutout(scope.row.shouyueName).length>2&&index==1">...</span></span>
                        </el-tooltip>
                      </div>
                    </template>
                  </el-table-column>
                <el-table-column prop="zhibiaoType" label="指标类别" min-width="120" header-align="center" align="center"></el-table-column>
                <el-table-column prop="zhibiaoName" label="指标名称" min-width="120" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column prop="weight" label="权重" min-width="120" header-align="center" align="center"></el-table-column>
                <el-table-column prop="targetValue" label="目标值" min-width="120" header-align="center" align="center"></el-table-column>
                <el-table-column prop="unit" label="单位" min-width="120" header-align="center" align="center"></el-table-column>
                <el-table-column prop="tbSz" label="填报值" min-width="120" header-align="center" align="center">
                </el-table-column>
                <el-table-column label="得分" width="150" prop="zbDf"  header-align="center" align="center">
                    <template slot-scope="scope">
                        <el-input v-model="scope.row.zbDf" placeholder="得分" oninput ="value=value.replace(/[^0-9.]/g,'')" @change="saveWorkZbdl(scope.row)"></el-input>
                    </template>
                </el-table-column>
                <el-table-column label="操作" width="100"  header-align="center" align="center" fixed="right">
                    <template slot-scope="scope">
                        <el-button type="primary" v-if="scope.row.tbzbStatus<2" plain @click="confirmTianbao(scope.row.zbId)">提交</el-button>
                    </template>
                </el-table-column>
            </el-table>
</template>
<script>
import {fetchList,delObj,saveWorkZbdx,confirmTianbaodx} from '@/api/hetongrenwu/gongzuorenwushu/workAssigntbsh'
export default {
  name:"tianbaoTable-form",
  props:{
    zhiShow:0
  },
  data(){
    return{
      dataList:[],
      dataListLoading:false,
      form:{},
      radio:'1',
      radioTwo:1,
      tableData:[ ],
      pageIndex:1,
      pageSize: 10,
      totalPage: 0,
      gridData:[
        {
          zhiwu: '经理',
          name: '王小虎',
          status: '退回'
        }
      ],
      leveList:[
        {value:"所属单位部门负责人",label:"所属单位部门负责人"}
      ],
      completion:"",
      dialogVisible:false,
      tbDialog:{},
      searchadvanced: true,
      searchheight: '0'
    }
  },
  watch:{
    radio(value){
      if(value){
        this.getDataList();
      }
    }
  },
  created() {
    this.getDataList()
  },
  methods:{
    selectChange(val){
      this.$emit('tbTableChild',val)
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true
      fetchList(Object.assign({
        type:this.radio,
        fayuename:this.form.fayueName,
        shouyuename:this.form.shouyueName,
        current: this.pageIndex,
        size: this.pageSize,
        contFillStatus:1,
        dingtype:1,
        tbzbStatus:1//结果填报-提交状态
      })).then(response => {
        this.dataList = response.data.data.records;
        this.totalPage = response.data.data.total
      })
      this.dataListLoading = false
    },
    init(data){
     //console.log(data);
      this.form=data;
      this.radio=data.radio;
      this.getDataList()
    },
    saveWorkZbdl(row){
      var params={
        id:row.zbId,
        zbDf:row.zbDf
      }
      saveWorkZbdx(params).then(response => {
        this.getDataList()
      })
    },
    confirmTianbao(data){
      confirmTianbaodx(data).then(response => {
        this.$message.closeAll();
        this.$message.success('提交成功')
        this.getDataList();
      })
    },
    //拆分数据
    cutout(cellValue) {
      if (cellValue) {
        var c = cellValue.split(",");
        if(c.size<1){
          c.push('-');
          c.push('-');
        } else if(c.size<2){
          c.push('-');
        }
        return c;
      }
    },
  }
}
</script>

<style>

</style>
